<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$postdata=get_postdata();
$getmid = intval($postdata['getmid']);
$commenttype = intval($postdata['commenttype']);
$msg = trim($postdata['msg']);
$setting=pdo_get('jy_kefu_set',array('uniacid'=>$_SESSION['uniacid']),array('title','isremind','sharetitle','sharedes','sharepicurl','kefuremindtime','bgcolor','nologo','isautomsg','autotype','isunfollow','filterword','confcolor','groupremind','groupremindtime','groupshowindex','showgroupnum','jyrobotkey','isjyrobot'));
if(empty($_SESSION['uid'])){
	$return['error'] = 1;
	$return['msg'] = '请先登录会员！';
	exi($return);
}else{
	$data['setmid'] = $_SESSION['uid'];
}
$ispingjia = pdo_get('jy_kefu_comments',array('uniacid'=>$_SESSION['uniacid'],'setmid'=>$data['setmid']));
if($ispingjia){
	$return['error'] = 1;
	$return['msg'] = '您已经评价过了！';
	exi($return);
}
$data['kefuid'] = $getmid;
$data['createtime'] = TIMESTAMP;
$data['msg'] = $msg;
$data['uniacid'] = $_SESSION['uniacid'];
$data['type'] = $commenttype;
pdo_insert('jy_kefu_comments',$data);
$chat = pdo_get('jy_kefu_member_chat',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$data['setmid']));
$passtime = TIMESTAMP-$chat['lasttime'];
if($setting['isremind'] == 1 && $passtime > $setting['kefuremindtime']){
	$tplcon = $data['msg'];
}
$tplcon = cfc('tools')->filterword($tplcon,$setting['filterword']);
$kefumid = pdo_get('core_fans',array('uniacid'=>$_SESSION['uniacid'],'openid'=>$_SESSION['openid']),array('mid'));
if(!empty($setting['tpl_kefu'])){
		$url = custom_url(array('jy_kefu/chat/',array('getmid'=>$data['setmid'])),true);
		$topcolor = '#980000';
		$msg = array(
							'first' => array(
								'value' => $data['nickname'].'向你评论了！',
								'color' => '#990000'
							),
							'keyword1' => array(
								'value' => $tplcon,
								'color' => '#ff510'
							),
							'keyword2' => array(
								'value' => "点击此消息尽快查看",
								'color' => '#ff510'
							),
							'remark' => array(
								'value' => '评论时间：'.date("Y-m-d H:i:s",TIMESTAMP),
								'color' => '#ff510'
							),							
		);
		$res = cfc('account')->sendTplNotice($kefumid,$setting['tpl_kefu'],$msg,$url,$topcolor);
}
$return['error'] = 0;
exi($return);